<script>
export default {
  name: 'IconLive',
  props: {
    type: {
      type: String,
      default: 'gray'
    },
    status: {
      type: Number,
      default: 2
    },
    shape: {
      type: String,
      default: 'wave'
    }
  }
};
</script>

<template>
  <view v-if="shape === 'wave'" :class="['live-status', type]">
    <view>{{ status === 2 ? '直播中' : '直播结束' }}</view>
    <view v-if="status === 2" class="live-icon">
      <view class="bar"></view>
      <view class="bar"></view>
      <view class="bar"></view>
    </view>
  </view>

  <view v-else-if="shape === 'circle'" class="live-box">
    <view class="live-icon">
      <view class="outer-circle">
        <view class="inner-circle"></view>
      </view>
    </view>
    <view>轻触进入直播间</view>
  </view>
</template>

<style scoped lang="scss">

.live-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 40px;
  height: 50px;
  padding: 0 20px;
  font-size: 26px;

  &.red {
    background: linear-gradient(#ffb084 0%, #fb4026 100%);
  }

  .live-icon {
    width: 30px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    position: relative;
    margin-left: 6px;
    padding-bottom: 12px;
  }

  .bar {
    width: 6px;
    background-color: #fff;
    border-radius: 6px;
    animation: pulse 0.4s alternate infinite;
    transform-origin: 100% 100%;
  }

  .bar:nth-child(1) {
    height: 80%;
    animation-delay: 0.3s;
  }

  .bar:nth-child(2) {
    height: 80%;
    animation-delay: -0.3s;
  }

  .bar:nth-child(3) {
    height: 80%;
    animation-delay: -0.2s;
  }
}

.live-box {
  display: flex;
  align-items: center;
  color: #ffffff;
  background: linear-gradient(to right, rgba(50, 45, 4, 0.63), rgba(0, 0, 0, 0.63));
  font-size: 32px;
  border-radius: 16px;
  padding: 26px 26px;

  .live-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 12px;

    .outer-circle {
      width: 36px;
      height: 36px;
      border: 2px solid #ffffff;
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;

      .inner-circle {
        width: 20px;
        height: 20px;
        background-color: #ffffff;
        border-radius: 50%;
        animation: zoom .6s alternate infinite;
      }
    }
  }
}

@keyframes zoom {
  0% {
    transform: scale(0.8);
  }
  100% {
    transform: scale(1.1);
  }
}

@keyframes pulse {
  0% {
    transform: scaleY(1);
  }
  100% {
    transform: scaleY(0.6);
  }
}

</style>
